<?php //pack11class

class SpecialsManager extends Module {

    public $languages="";

    public function setup() {

        $langsData=array();
        $langsArray=array();
        foreach(LanguagesManager::getLanguages() as $language) {
            array_push($langsData,"`lang".$language->id."`");
            array_push($langsArray,$language->id);
        }
        $langs=implode(", ",$langsData);
        $this->languages=implode(",",$langsArray);

        $specialsData=MySQLGet::process("Select * from ".MySQL::TABLE_SPECIALS." order by `priority`;");
        foreach($specialsData as $item) {
            $line=new SpecialsManagerItem();
            $line->id="special_".$item["id"];
            $line->setClass("SpecialsManagerItem");
            $prior=new TextInput();
            $prior->id="special_".$item["id"]."_priority";
            $prior->setClass("SpecialsManagerPriority");
            $prior->setBody($item["priority"]);
            $prior->events='onkeydown="SpecialsManager.setState(this)" onkeyup="SpecialsManager.setState(this)" onblur="SpecialsManager.setState(this)" onclick="SpecialsManager.setState(this)"';
            $line->addChild($prior);

            foreach(LanguagesManager::getLanguages() as $language) {
                $input=new TextInput();
                $input->id="special_".$item["id"]."_".$language->id;
                $input->setClass("SpecialsManagerInput");
                if(!is_null($item["lang".$language->id]))$input->extra_value=$item["lang".$language->id];
                $input->setBody($item["lang".$language->id]);
                $input->label=$language->label;
                $input->events='onkeydown="SpecialsManager.setState(this)" onkeyup="SpecialsManager.setState(this)" onblur="SpecialsManager.setState(this)" onclick="SpecialsManager.setState(this)"';
                $line->addChild($input);
            }
            $this->addChild($line);
        }
    }

}
?>
